//
//  LZSquareButton.m
//  百思不得姐
//
//  Created by 郝庆 on 16/5/22.
//  Copyright © 2016年 haoqing. All rights reserved.
//

#import "LZSquareButton.h"
#import "LZMeSquare.h"
#import <UIButton+WebCache.h>

@implementation LZSquareButton

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self setBackgroundImage:[UIImage imageNamed:@"mainCellBackground"] forState:UIControlStateNormal];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageView.lz_y = self.lz_height * 0.15;
    self.imageView.lz_height = self.lz_height * 0.5;
    self.imageView.lz_width = self.imageView.lz_height;
    self.imageView.lz_centerX = self.lz_width * 0.5;
    
    self.titleLabel.lz_x = 0;
    self.titleLabel.lz_y = self.imageView.lz_bottom;
    self.titleLabel.lz_width = self.lz_width;
    self.titleLabel.lz_height = self.lz_height - self.titleLabel.lz_y;
    
}

#pragma mark - 给模型属性赋值
- (void)setSquare:(LZMeSquare *)square
{
    _square = square;
    
    [self setTitle:square.name forState:UIControlStateNormal];
    [self sd_setImageWithURL:[NSURL URLWithString:square.icon] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"setup-head-default"]];
    
}

@end
